<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>检测浏览器类型</title>
</head>
<body>
    <input type="button" value="检测" class="btn">
</body>
<script>
    document.getElementsByClassName("btn")[0].onclick = function(){
        alert(window.navigator.userAgent);
        document.write(window.navigator.userAgent);
    }
</script>
</html>